<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="common/common_head :: commonHeader('通知定义管理')"/>
</head>

<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-condition">
            <form id="noticeDefinitionForm" class="form-inline" th:action="@{/noticeDefinition/list}">
                <div class="select-list">
                    <ul>
                        <li>
                            通知类型：<input type="text" id="kind" name="kind"/>
                        </li>
                        <li>
                            <button id="noticeDefinitionSearchBtn" type="button"
                                    class="btn btn-primary btn-rounded btn-sm"><i class="fa fa-search"></i>&nbsp;搜索
                            </button>
                            <button class="btn btn-warning btn-rounded btn-sm" type="reset"><i class="fa fa-eraser"></i>&nbsp;重置
                            </button>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-info">
            <div class="btn-group hidden-xs toolbar" id="noticeDefinitionToolBar" role="group">
                <a class="btn btn-outline btn-success btn-rounded" onclick="toAdd()">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-outline btn-success btn-rounded" onclick="toEdit()">
                    <i class="fa fa-edit"></i> 编辑
                </a>
                <a class="btn btn-outline btn-danger btn-rounded" onclick="deleteNotice()">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <table id="noticeDefinition"></table>
        </div>
    </div>
</div>

<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>

<script type="text/javascript">
    var searcher = Searcher.createBS('#noticeDefinition',
        [
            {checkbox: true},
            {title: "通知类型", field: "kind", align: 'center', valign: 'middle'},
            {title: "备注", field: "remark", align: 'center', valign: 'middle'},
            {title: "创建时间", field: "createDate", align: 'center', valign: 'middle'}
        ]
    );

    /**
     * 跳转至新增页
     */
    function toAdd() {
        var index = Dialog.openUrl("新增", ctxPath + '/modules/sys/notice/notice_add.html', {
            area: ['900px', '700px'],
            maxmin: true,
            end: function () {
                searcher.refresh()
            }
        });
        layer.full(index);
    }

    /**
     * 编辑
     */
    function toEdit() {
        var pkId = searcher.getSelectedRows("pkId");
        if (pkId.length != 1) {
            Dialog.errorMsg("请选择一行进行编辑!");
            return;
        }
        var index = Dialog.openUrl("编辑", ctxPath + '/noticeDefinition/toEdit/' + pkId, {
            area: ['900px', '650px'], end: function () {
                searcher.refresh()
            }
        });
        layer.full(index);
    }

    /**
     * 删除
     */
    function deleteNotice() {
        let pkIds = searcher.getSelectedRows("pkId");
        if (pkIds.length < 1) {
            Dialog.errorMsg("请至少选择一行!");
            return false;
        }

        Dialog.confirm('确定删除？', function () {
            Page.ajaxPOST(ctxPath + "/noticeDefinition/delete", {pkIds: pkIds}, function () {
                Dialog.msg("操作成功", function () {
                    searcher.refresh()
                });
            });
        });
    }

</script>
</body>
</html>